<?
	use_db_wordpress();

	$query = @mysql_query("SELECT * FROM `$wp_users`");

	if(mysql_errno()) {
		echo "<p>There are no users.</p>";
	} else {
		while($row = @mysql_fetch_assoc($query)) {

			$id = "";
			$username = "";
			$password = "";
			$email = "";
			$url = "";
			$date_added = "";
			$aim = "";
			$about = "";
			$first_name = "";
			$last_name = "";
			$jabber = "";
			$user_lever = "";
			$nice_name = "";
			$yahoo = "";

			$id = $row['ID'];
			$username = $row['user_login'];
			$password = $row['user_pass'];
			$email = $row['user_email'];
			$url = $row['user_url'];
			$date_added = strtotime($row['user_registered']);
			$yahoo = $row['meta_value'];
			
			$meta_query = @mysql_query("SELECT * FROM `$wp_usermeta` WHERE `user_id`='$id' AND `meta_key`='aim'");
			while($row = @mysql_fetch_assoc($meta_query)) {
				$aim = $row['meta_value'];
			}

			$meta_query = @mysql_query("SELECT * FROM `$wp_usermeta` WHERE `user_id`='$id' AND `meta_key`='description'");
			while($row = @mysql_fetch_assoc($meta_query)) {
				$about = $row['meta_value'];
			}

			$meta_query = @mysql_query("SELECT * FROM `$wp_usermeta` WHERE `user_id`='$id' AND `meta_key`='first_name'");
			while($row = @mysql_fetch_assoc($meta_query)) {
				$first_name = $row['meta_value'];
			}

			$meta_query = @mysql_query("SELECT * FROM `$wp_usermeta` WHERE `user_id`='$id' AND `meta_key`='last_name'");
			while($row = @mysql_fetch_assoc($meta_query)) {
				$last_name = $row['meta_value'];
			}

			$meta_query = @mysql_query("SELECT * FROM `$wp_usermeta` WHERE `user_id`='$id' AND `meta_key`='jabber'");
			while($row = @mysql_fetch_assoc($meta_query)) {
				$jabber = $row['meta_value'];
			}

			$meta_query = @mysql_query("SELECT * FROM `$wp_usermeta` WHERE `user_id`='$id' AND `meta_key`='nickname'");
			while($row = @mysql_fetch_assoc($meta_query)) {
				$nice_name = $row['meta_value'];
			}

			$meta_query = @mysql_query("SELECT * FROM `$wp_usermeta` WHERE `user_id`='$id' AND `meta_key`='wp_user_level'");
			while($row = @mysql_fetch_assoc($meta_query)) {
				$user_lever = $row['meta_value'];
			}

			$meta_query = @mysql_query("SELECT * FROM `$wp_usermeta` WHERE `user_id`='$id' AND `meta_key`='yim'");
			while($row = @mysql_fetch_assoc($meta_query)) {
				$yahoo = $row['meta_value'];
			}
			
			drizzo_db_connect();
			
			$drizzo_insert = "INSERT INTO `$drizzo_users` (`ID`, `username`, `password`, `email`, `url`, `date_added`, `aim`, `about`, `first_name`, `last_name`, `jabber`, `nice_name`, `user_level`, `yahoo`) VALUES ('', '$username', '$password', '$email', '$url', '$date_added', '$aim', '$about', '$first_name', '$last_name', '$jabber', '$nice_name', '$user_level', '$yahoo')";
			@mysql_query($drizzo_insert);

			use_db_wordpress();
		}
		echo "<p>" . @mysql_num_rows($query) . " users imported.</p>";
	}
?>
